﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class percentDeduction : Form
    {
        ListBox parent;
        List<int> checkedIndices = new List<int>();
        public percentDeduction(ListBox parent)
        {
            this.parent = parent;
            InitializeComponent();
            percentDeductionCheckedListBox.Items.Clear();
            foreach (string strCol in parent.Items)
            {
                percentDeductionCheckedListBox.Items.Add(strCol);
            }
        }

        private void percentDeductionSaveButton_Click(object sender, EventArgs e)
        {
            foreach (int checkedItemIndex in percentDeductionCheckedListBox.CheckedIndices)
            {
                checkedIndices.Add(checkedItemIndex);
            }
            this.Close();
        }
        
        public percentDeduction getPercentDeductions()
        {
            return this;
        }

        private void percentDeductionCancelButton_Click(object sender, EventArgs e)
        {
           foreach (int checkedItemIndex in percentDeductionCheckedListBox.CheckedIndices)
            {
                if (!checkedIndices.Contains(checkedItemIndex))
                    percentDeductionCheckedListBox.SetItemChecked(checkedItemIndex, false);
            }
            this.Close();
        }
    }
}
